1 RMarkdown

Is amazing.

1.2 Key Resources

# PDF Knitting Setup: https://yihui.name/tinytex/ 
# install.packages("tintex")
# tinytex::install_tinytex()

2 How Rmarkdown Works

3 Header 1

3.1 Header 2

3.1.1 Header 3

4 Working with Text

Free-form text.

Make text bold.

Make text italics.

Make text bold + italics.

Talk about code - the tidyverse is awesome

Unordered List:

Ordered List:

  1. First point

  2. Second point

  3. More points

5 Tabset

5.1 Tab 1

This is Tab 1

5.2 Tab 2

This is Tab 2

6 Images

Business Science Logo

Business Science Logo

Business Science Logo

7 Code

Read in data and print to HTML. Notice effect of df_print: paged option for HTML.

bike_orderlines_tbl <- read_rds("../00_data/bike_sales/data_wrangled/bike_orderlines.rds")

bike_orderlines_tbl

We can do data manipulations too. Try changing the YAML code_folding option from none to hide to show.

revenue_by_category_tbl <- bike_orderlines_tbl %>%
  select(category_2, category_1, total_price) %>%
  
  group_by(category_2, category_1) %>%
  summarise(total_revenue = sum(total_price)) %>%
  ungroup() %>%
  
  arrange(desc(total_revenue)) %>%
  mutate(category_2 = as_factor(category_2) %>% fct_rev())

8 Plots

Plotting works as expected. Try changin:

Static Plots:

g <- revenue_by_category_tbl %>%
  ggplot(aes(category_2, total_revenue, fill = category_1)) +
  
  # Geoms
  geom_col() +
  coord_flip() +
  
  # Formatting
  scale_fill_tq() +
  scale_y_continuous(labels = scales::dollar_format(scale = 1e-6, suffix = "M")) +
  theme_tq() +
  labs(
    title = "Total Revenue by Category",
    x = "", y = "", fill = ""
  )

g
Revenue by Category

Revenue by Category

Interactive plots:

ggplotly(g)

9 Tables

Static Tables:

table_formatted_tbl <- revenue_by_category_tbl %>%
  mutate(total_revenue = scales::dollar(total_revenue)) %>%
  rename_all(.funs = ~ str_replace(., "_", " ") %>%
               str_to_title()) 

table_formatted_tbl %>% knitr::kable()
Category 2 Category 1 Total Revenue
Cross Country Race Mountain $19,224,630
Elite Road Road $15,334,665
Endurance Road Road $10,381,060
Trail Mountain $9,373,460
Over Mountain Mountain $7,571,270
Triathalon Road $4,053,750
Cyclocross Road $2,108,120
Sport Mountain $1,932,755
Fat Bike Mountain $1,052,620

Dynamic Tables:

table_formatted_tbl

10 Footnotes

This is some text with a Footnote1. This is a second Footnote2.


  1. Citation for Footnote 1↩︎

  2. Citatin for Footnote 2↩︎